<!DOCTYPE html>
<html lang="zh_cn">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>test</title>
  <link href="../css/bootstrap.min.css" rel="stylesheet">
  <link href="../css/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
  
  <table id="table">

  </table>

  <script src="../js/jquery.min.js"></script>
  <script src="../js/bootstrap.min.js"></script>
  <script src="../js/bootstrap-table.js"></script>
  <script src="../js/bootstrap-table-zh-CN.js"></script>
  <script src="../js/mergecell.js"></script>
  <script>
    // 原始数据
    let data=[
      {
        date:'2021-1-4',
        name:'陈瑞',
        count:97
      },
      {
        date:'2021-1-4',
        name:'徐毅',
        count:97
      },
      {
        date:'2021-1-4',
        name:'张弛',
        count:70
      },
      {
        date:'2021-1-4',
        name:'徐毅',
        count:90
      },
      {
        date:'2021-1-4',
        name:'陈瑞',
        count:98
      },
      {
        date:'2021-1-4',
        name:'西林',
        count:46
      },
      {
        date:'2021-1-5',
        name:'西林',
        count:43
      },
      {
        date:'2021-1-5',
        name:'陈瑞',
        count:91
      },
      {
        date:'2021-1-5',
        name:'西林',
        count:93
      }
    ]

    
    // 合并优先级
    let sortKeys=['date','name']

    // 对数据进行排序（用于初始化表格）
    let sortResArr=autoSort(data,sortKeys)

    // 获得合并单元格坐标
    let mergeArr=getMergePoints(sortResArr,sortKeys)


    console.log(sortResArr)
    console.log(mergeArr)

    // 初始化表格
    $('#table').bootstrapTable({
      data:sortResArr,
      columns: [
        {
          field: 'date',
          title: '日期'
        }, 
        {
          field: 'name',
          title: '姓名'
        }, 
        {
          field: 'count',
          title: '分数'
        }
      ]
    })

    // 合并单元格
    for (let item of mergeArr){
      $('#table').bootstrapTable('mergeCells',item)
    }



    
  </script>
</body>
</html>